<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        hr{
            border-bottom: 2px #000000 solid;
        }
        textarea{
            width: 170px;
            height: 85px;
            border: 1px #B06FEB solid;
            margin-left: 30px;
        }
        span{
            margin-right: 160px;
        }
        .a1{
           margin-left: 30px;
        }
        .s1{
            margin-right:115px;
        }
    </style>
</head>
<body>
<h3>点击复制可以复制textarea中的内容，任何textarea下点击粘贴按钮，可以将复制的内容粘贴到该textarea中</h3>
<hr/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>内容：</span>
<span>内容：</span>
<span>内容：</span>
<span>内容：</span>
<br/>
<textarea id="f1"></textarea>
<textarea id="f2"></textarea>
<textarea id="f3"></textarea>
<textarea id="f4"></textarea><br/>
<button class="a1" onclick="run1()">复制</button>
<button class="s1" onclick="str1()">粘贴</button>
<button  onclick="run2()">复制</button>
<button  class="s1" onclick="str2()">粘贴</button>
<button  onclick="run3()">复制</button>
<button  class="s1" onclick="str3()">粘贴</button>
<button  onclick="run4()">复制</button>
<button  class="s1" onclick="str4()">粘贴</button>
</body>
<script>
    var s1 = document.getElementById("f1");
    var s2 = document.getElementById("f2");
    var s3 = document.getElementById("f3");
    var s4 = document.getElementById("f4");
    var a1="",a2="",a3="",a4="";
    // 复制
    function run1() {
        // 执行浏览器复制命令用户定义的代码区域用户定义的代码区域
        document.execCommand("Copy");
        a1=s1.value;
    }
    function run2() {
        // 执行浏览器复制命令用户定义的代码区域用户定义的代码区域
        document.execCommand("Copy");
        a2=s2.value;
    }
    function run3() {
        // 执行浏览器复制命令用户定义的代码区域用户定义的代码区域
        document.execCommand("Copy");
        a3=s3.value;
    }
    function run4() {
        // 执行浏览器复制命令用户定义的代码区域用户定义的代码区域
        document.execCommand("Copy");
        a4=s4.value;
    }
//    粘贴
    function str1() {
        if (a2 != "") {
            s1.value=a2;
        }else if (a3 != "") {
            s1.value=a3;
        }else if (a4 != "") {
            s1.value=a4;
        }else {
            s1.value=a1;
        }
    }
    function str2() {
        if (a1 != "") {
            s2.value=a1;
        }else if (a3 != "") {
            s2.value=a3;
        }else if (a4 != "") {
            s2.value=a4;
        }else {
            s2.value=a2;
        }

    }
    function str3() {
        if (a1 != "") {
            s3.value=a1;
        }else if (a2 != "") {
            s3.value=a2;
        }else if (a4 != "") {
            s3.value=a4;
        }else{
            s3.value=s3;
        }
    }
    function str4() {
        if (a1 != ""){
            s4.value=a1;
        }else if (a2 != "") {
            s4.value=a2;
        }else if (a3 != "") {
            s4.value=a3;
        }else {
            s4.value=a4;
        }
    }
</script>
</html>